package com.example.controller;

import com.example.entity.ProductOrder;
import com.example.service.ProductOrderService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @Auther: Nostalgia
 * @Date: 2020/7/6 17:00
 * @Description:
 */
@Controller
@RequestMapping("/productOrder")
public class ProductOrderController {

    @Autowired
    private ProductOrderService service;

    @RequestMapping("/getAllProductOrder")
    @ResponseBody
    /**
     * 获取所有商品订单
     * @return
     */
    public Object getAllProductOrder(int pageNo,int pageSize,String productName){
        PageHelper.offsetPage((pageNo-1)*pageSize,pageSize);
        List<ProductOrder> productOrderList =service.getAllProductOrder(productName);
        PageInfo<ProductOrder> pageInfo=new PageInfo<ProductOrder>(productOrderList);
        return pageInfo;
    }
    @RequestMapping("/del/{id}")
    @ResponseBody
    public int delProductOrderById(@PathVariable int id){
        return service.deleteProductOrderById(id);
    }

    @RequestMapping("/update/{id}")
    @ResponseBody
    public int updateStatus(@PathVariable int id){
        return service.updateStatus(id);
    }
}
